package com.netease.xone.activity;

import protocol.meta.User;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import com.netease.pkgRelated.XoneConsts;
import com.netease.xone.R;
import com.netease.xone.fragment.FragmentEditProfile;


public class ActivityEditProfile extends ActivityX1Base{

    public static void startActivity(Context context, User user){
        Intent i = new Intent(context, ActivityEditProfile.class);
        i.putExtra(XoneConsts.BUNDLE_KEY.USER_DATA, user);
        context.startActivity(i);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        User user = getIntent().getParcelableExtra(XoneConsts.BUNDLE_KEY.USER_DATA);
        if(user == null){
            finish();
            return;
        }

        FrameLayout linear = new FrameLayout(this);
        linear.setId(R.id.activity_edit_profile_container_id);
        setContentView(linear);

        if (findViewById(R.id.activity_edit_profile_container_id) != null && savedInstanceState == null) {
            FragmentEditProfile f = FragmentEditProfile.newInstance(user);
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.activity_edit_profile_container_id, f);
            ft.commit();
        }
    }



}
